<%--
  Created by IntelliJ IDEA.
  User: FENG1
  Date: 2022/5/6
  Time: 15:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";%>
<html>
<head>
    <base href="<%=basePath%>">
    <title>修改角色信息</title>
    <link href="static/component/pear/css/pear.css" rel="stylesheet" />
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="layui-form-item">
                <input type="hidden" name="rid" value="${Role.rid}">
                <label class="layui-form-label">角色名称</label>
                <div class="layui-input-block">
                    <input type="text" name="rName" value="${Role.rName}" lay-verify="title" autocomplete="off"
                           placeholder="请输入角色名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">角色创建人</label>
                <div class="layui-input-block">
                    <input type="text" name="rCreator" value="${Role.rCreator}" lay-verify="title" autocomplete="off"
                           placeholder="请输入角色创建人" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="remark" value="${Role.remark}" lay-verify="title" autocomplete="off"
                           placeholder="请输入角色备注" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <c:if test="${Role.rState=='可用'}" var="f">
                    <input type="radio" name="rState" value="可用" title="可用"checked>
                    <input type="radio" name="rState" value="禁用" title="禁用">
                </c:if>
                <c:if test="${!f}">
                    <input type="radio" name="rState" value="可用" title="可用">
                    <input type="radio" name="rState" value="禁用" title="禁用" checked>
                </c:if>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="static/component/layui/layui.js"></script>
<script src="static/component/pear/pear.js"></script>
<script>
    layui.use(['form','jquery'],function(){
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(user-save)', function(data){
            $.post("/role/upRole",data.field,function (result) {
                if(result.success){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        window.close();
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("user-table");
                    });
                }else{
                    layer.msg(result.msg,{icon:2,time:1000});
                }
            })
        });
    })
</script>
</body>
</html>